<?php
declare (strict_types=1);

namespace app\api\model\yuql;

use think\Model;

/**
 * @mixin \think\Model
 */
class Rebate extends Model
{
    protected $table = '2008a_store_rebates';

    /**
     * yuql
     * 存入返佣库
     * @param $data
     * @return Rebate|Model
     */
    public static function userPaySetRebate($data)
    {
        $result = Rebate::create($data);
        return $result;
    }

    /**
     * yuql
     * 查询此用户信息
     * @param $data
     * @return Login|array|mixed|Model|null
     */
    public static function userOne($data)
    {
        $result = Login::where($data)->find();
        return $result;
    }

    /**
     * yuql
     * 查询当前用户信息
     * @param $data
     * @return Login|array|mixed|Model|null
     */
    public static function userPresentOne($data)
    {
        $result = Cashe::where($data)->find();
        return $result;
    }

    /**
     * yuql
     * 查询出所有佣金信息
     * @param $data
     * @return array
     */
    public static function rebateMoney($data)
    {
        $result = Rebate::where($data)->select()->toArray();
        return $result;
    }

    /**
     * yuql
     * 查询上一级信息，修改佣金库存
     * @param $data
     * @param $pidMoney
     */
    public static function userPidMoneySet($data, $pidMoney)
    {
        $result = Cashe::where($data)->find();
        $result->cash_money = $pidMoney;
        $result->save();
        return $result;
    }

    /**
     * yuql
     * 查询当前用户信息，修改佣金库存
     * @param $data
     * @param $PresentMoney
     */
    public static function userPresentMoney($data, $PresentMoney)
    {
        $result = Cashe::where($data)->find();
        $result->cash_money = $PresentMoney;
        $result->save();
        return $result;
    }
}
